package org.luxor.eshop.storage.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.luxor.eshop.storage.entity.CommodityEntity;

/**
 * 商品/库存
 *
 * @author administrator @date 2020-12-04 15:58:21
 */
@Mapper
public interface CommodityMapper extends BaseMapper<CommodityEntity> {

    /**
     * 根据编号获得商品信息
     *
     * @param commodityCode 商品编号
     * @return 商品信息
     */
    CommodityEntity getByCommodityCode(String commodityCode);

    /**
     * 扣减库存数
     *
     * @param quantity      扣减数量
     * @param commodityCode 商品编码
     */
    void deductInventory(@Param("quantity") Integer quantity, @Param("commodityCode") String commodityCode);
}
